/*
 * Decompiled with CFR 0_132.
 * 
 * Could not load the following classes:
 *  org.lwjgl.opengl.EXTFramebufferObject
 *  org.lwjgl.opengl.GL11
 */
package forward.Util.Render;

import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import org.lwjgl.opengl.EXTFramebufferObject;
import org.lwjgl.opengl.GL11;

public class OutlineUtils {
	public static void renderOne() {
		OutlineUtils.checkSetupFBO();
		GL11.glPushAttrib((int) 1048575);
		GL11.glDisable((int) 3008);
		GL11.glDisable((int) 3553);
		GL11.glDisable((int) 2896);
		GL11.glEnable((int) 3042);
		GL11.glBlendFunc((int) 770, (int) 771);
		GL11.glLineWidth((float) 3.0f);
		GL11.glEnable((int) 2848);
		GL11.glEnable((int) 2960);
		GL11.glClear((int) 1024);
		GL11.glClearStencil((int) 15);
		GL11.glStencilFunc((int) 512, (int) 1, (int) 15);
		GL11.glStencilOp((int) 7681, (int) 7681, (int) 7681);
		GL11.glPolygonMode((int) 1032, (int) 6913);
	}

	public static void renderTwo() {
		GL11.glStencilFunc((int) 512, (int) 0, (int) 15);
		GL11.glStencilOp((int) 7681, (int) 7681, (int) 7681);
		GL11.glPolygonMode((int) 1032, (int) 6914);
	}

	public static void renderThree() {
		GL11.glStencilFunc((int) 514, (int) 1, (int) 15);
		GL11.glStencilOp((int) 7680, (int) 7680, (int) 7680);
		GL11.glPolygonMode((int) 1032, (int) 6913);
	}

	public static void renderFour() {
		OutlineUtils.setColor(new Color(255, 255, 255));
		GL11.glDepthMask((boolean) false);
		GL11.glDisable((int) 2929);
		GL11.glEnable((int) 10754);
		GL11.glPolygonOffset((float) 1.0f, (float) -2000000.0f);
		OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
	}

	public static void renderFive() {
		GL11.glPolygonOffset((float) 1.0f, (float) 2000000.0f);
		GL11.glDisable((int) 10754);
		GL11.glEnable((int) 2929);
		GL11.glDepthMask((boolean) true);
		GL11.glDisable((int) 2960);
		GL11.glDisable((int) 2848);
		GL11.glHint((int) 3154, (int) 4352);
		GL11.glEnable((int) 3042);
		GL11.glEnable((int) 2896);
		GL11.glEnable((int) 3553);
		GL11.glEnable((int) 3008);
		GL11.glPopAttrib();
	}

	public static void setColor(Color c) {
		GL11.glColor4d((double) ((float) c.getRed() / 255.0f), (double) ((float) c.getGreen() / 255.0f),
				(double) ((float) c.getBlue() / 255.0f), (double) ((float) c.getAlpha() / 255.0f));
	}

	public static void checkSetupFBO() {
		Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer();
		if (fbo != null && fbo.depthBuffer > -1) {
			OutlineUtils.setupFBO(fbo);
			fbo.depthBuffer = -1;
		}
	}

	public static void setupFBO(Framebuffer fbo) {
		EXTFramebufferObject.glDeleteRenderbuffersEXT((int) fbo.depthBuffer);
		int stencil_depth_buffer_ID = EXTFramebufferObject.glGenRenderbuffersEXT();
		EXTFramebufferObject.glBindRenderbufferEXT((int) 36161, (int) stencil_depth_buffer_ID);
		EXTFramebufferObject.glRenderbufferStorageEXT((int) 36161, (int) 34041,
				(int) Minecraft.getMinecraft().displayWidth, (int) Minecraft.getMinecraft().displayHeight);
		EXTFramebufferObject.glFramebufferRenderbufferEXT((int) 36160, (int) 36128, (int) 36161,
				(int) stencil_depth_buffer_ID);
		EXTFramebufferObject.glFramebufferRenderbufferEXT((int) 36160, (int) 36096, (int) 36161,
				(int) stencil_depth_buffer_ID);
	}
}
